<template>
<div class="recommend-list">
    <div class="recommend-item" v-for="(item,index) in recommendList" :key="index">
        <img :src="item.imageHost + item.mainImage">
        <p>{{item.name}}</p> <i>￥ {{item.price}}</i>
    </div>
</div>
</template>

<script>
import {
    getRecommend
} from '@/api'
export default {
    data() {
        return {
            recommendList: []
        }
    },
    created() {
        this.fetchRecommendList()
    },
    methods: {
        fetchRecommendList() {
            getRecommend().then(res => {
                this.recommendList = res
            })
        }
    }
}
</script>

<style lang="scss" scoped>
@import '@/common/style/mixin.scss';

.recommend-list {
    display: flex;
    flex-shrink: 0;
    flex-wrap: wrap;
    width: 100%;
    margin-top: 30px;
    padding-bottom: 150px;
    @include boxSizing;
    background: #fff;

    .recommend-item {
        display: flex;
        flex-direction: column;
        width: 50%;
        padding: 20px;
        @include boxSizing;
        border-bottom: 1px solid #dcdcdc;

        &:nth-child(2n-1) {
            border-right: 1px solid #dcdcdc;
        }

        img {
            width: 100%;
            height: 290px;
            margin: 0 auto;
        }

        p {
            height: 60px;
            padding: 20px 0;
            font-size: 26px;
            line-height: 40px;
            color: #333;
            overflow: hidden;
        }

        i {
            font-style: normal;
            font-size: 32px;
            color: $red;
        }
    }
}
</style>
